<div class="ops"><a href="javascript:void(0);" id="gettemps">一键获取所有模板</a><a href="addtemp">手动添加模板</a></div>
<div class="templist">
    <notempty name="templist">
        <form action="__URL__/temp_admin" method="post" id="tempsForm">
            <div class="topadmin">
                <span>选择操作：</span><select name="action" id="action">        	
                    <option value="del">删除</option>
                    <option value="up">上架</option>
                    <option value="down">下架</option>
                    <option value="rate">设置比例</option>
                </select>
                <span id="setrate"><span>比例：</span><select name="rate">
                        <option value="1">100%</option>
                        <option value="0.7">70%</option>
                        <option value="0.5">50%</option>
                    </select></span>
                <input type="submit" id="submit" value="提交" />
            </div>
            <div class="list-title">
                <span class="id"><input type="checkbox" onclick="reverse(this)"  id="checkall" value=""  /></span>
                <span class="title">标题</span>
                <span class="frontpage">缩略图</span>
                <span class="price">价格</span>
                <span class="count">市场销量</span>
                <span class="count1">本站销量</span>
                <span class="rate">返现比例</span>
                <span class="status">状态</span>
                <span class="op">管理</span>
            </div>
            <volist name="templist" id="v">
                <div class="temp-item">
                    <if condition="$up eq 1">
                        <if condition="$v['status'] eq 0">
                        <div class="po" id="{$v.id}">模板上架失败，请编辑完善模板信息</div>
                        </if>
                    </if>
                    <div class="po" style="display: none;" id="{$v.id}">模板上架失败，请编辑完善模板信息</div>
                    <span class="id"><input type="checkbox" name="id[]" value="{$v.id}"  /></span>
                    <span class="title"><a target="_blank" title="访问模板" href="http://<if condition='$v.type eq 1'>zxn<else/>zx</if>.taobao.com/detail.htm?id={$v.id}">{$v.title}</a></span>
                    <span class="frontpage"><img src="{$v.frontpage}" style="width:80px;height:125px;" /></span>
                    <span class="price">{$v.price}</span>
                    <span class="count">{$v.count}</span>
                    <span class="count1">{$v.count1}</span>
                    <span class="rate">{$v['rate']*100}%</span>
                    <span class="status"><if condition="$v.status eq 0">下架<else/><em  style="color: red;">上架</em></if></span>
                    <span class="op">
                        <if condition="$v.status eq 0">
        	<a href="javascript:;" onclick="grounding('{$v.id}',0)" title="设置为上架">上架</a>
                            <else/>
        	<a href="javascript:;" onclick="grounding('{$v.id}',1)" title="设置为下架">下架</a>
                        </if>       
                        <a href="javascript:;" onclick="edit('{$v.id}')">编辑</a>
                        <a href="__URL__/deltemp/id/{$v.id}" onclick="return a=confirm('确认删除？')" title="点击删除">删除</a>
                    </span>
                </div>    
            </volist>
            <div class="pages" style="margin:10px 0;">{$page}</div>
        </form>
        <else/>
        <div class="no-jilu">
            暂无模板记录
        </div>
    </notempty>
</div>

<script type="text/javascript">
    $(document).ready(function(e) {	
		$('#tips').omDraggable({handle:"h3"});	
        var h = window.screen.height;
        var w = window.screen.width;	
        $("#meng").css({"width":w+"px","height":h+"px"});
        $("#tips").css({"left":(w/2-100)+"px","top":(h/2-100)+"px"});
        $(".temp-item").mouseover(function(){
            $(this).css("background-color",'#eee');
        });	
        $(".temp-item").mouseleave(function(){
            $(this).css("background-color",'#fff');
        });	
        $("#gettemps").click(function(){
            if(confirm("一键获取会将您在淘宝装修市场的所有模板都获取到本站数据库中，但是否展示，由您自由操作。")){
                var name=prompt("请输入您的设计师账号","");
                if(name==""){
                    alert("设计师账号不得为空");
                    return false;		
                }
                else if(!name) return false;	
                $("#meng").fadeIn();
                $("#tips").html("<img src='/Public/images/wait.gif' width='100' /><br/>正在加载，请稍候").show();			
                $.post("__URL__/gettemps",{'designer':name},function(data){						
                    document.location.reload();
                },'json')
            }
        });	
        $("#tempsForm").submit(function(){			
            if($(":checkbox:checked").length==0){
                alert("请先选择模板");
                return false;
            }
        });	
        $("#action").change(function(){
            if($(this).val()=="rate") $("#setrate").show();
            else $("#setrate").hide();
        });
			
    });	
    function reverse(dom){  //全选与反选 
        $(".templist :checkbox").each(function () {  
            $(this).attr("checked", !$(this).attr("checked"));  
        });
        $(dom).attr("checked", !$(dom).attr("checked"));
    }	
    //编辑
    function edit(id){
        $.get('__URL__/selectid/id/'+id,function(data){
            $("#tips").html(data);
        });
        var h = window.screen.height;
        var w = window.screen.width;
        $("body").css({"overflow-Y":"hidden"});
        $("#tips").css({"left":(w/2-100)+"px","top":(h/2-100)+"px","display":"block"});
    }
    //上架
    function grounding(i,s){
        $.get('__URL__/changestatus/id/'+i+'/s/'+s,function(data){
            if(data == 1){
                location.reload() ;
            }else{
                $("#"+i).show();
            }
//             $("#idjs").html(data);
        });
    }

    
</script>